package com.training.array;

public class SelectSortDemo2 {
	public static void main(String args[]) {
		int[]a = {1,2,54541,3,13456,4,1231,4546,321};
		System.out.println("Before:");
		print(a);
		bubbleSort(a);
		System.out.println("\nAfter:");
		print(a);
	}
	public static void bubbleSort(int[] a) {
		for(int i = 0 ; i<a.length-1;i++) {
			for(int j = 0;j<a.length-i-1;j++) {
				if(a[j]>a[j+1]) {
					int temp = a[j];
					a[j] = a[j+1];
					a[j+1] = temp;
				}
			}
		}
	}
	public static void print(int[] a) {
		for(int t:a) {
			System.out.print(t+"\t");
		}
	}
}
